package com.pkx.guide.info.service.impl;

import com.pkx.guide.info.entity.TInfoGuideScheme;
import com.pkx.guide.info.mapper.TInfoGuideSchemeMapper;
import com.pkx.guide.info.service.TInfoGuideSchemeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 诱导屏方案策略表 服务实现类
 *
 * @author sunsy
 * @since 2023-11-16
 */
@Service
public class TInfoGuideSchemeServiceImpl extends ServiceImpl<TInfoGuideSchemeMapper, TInfoGuideScheme> implements TInfoGuideSchemeService {

    /**
     * 分页列表
     *
     * @param tInfoGuideScheme
     * @return
     */
    @Override
    public IPage<TInfoGuideScheme> pageList(Page page, TInfoGuideScheme tInfoGuideScheme) {
        LambdaQueryWrapper<TInfoGuideScheme> lambdaQueryWrapper = new QueryWrapper<TInfoGuideScheme>().lambda();
        return page(page, lambdaQueryWrapper);
    }

    /**
     * 列表查询
     *
     * @param tInfoGuideScheme
     * @return
     */
    @Override
    public List<TInfoGuideScheme> listByEntity(TInfoGuideScheme tInfoGuideScheme) {
        LambdaQueryWrapper<TInfoGuideScheme> lambdaQueryWrapper = new QueryWrapper<TInfoGuideScheme>().lambda();
        return list(lambdaQueryWrapper);
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public TInfoGuideScheme selectById(Integer id) {
        return getById(id);
    }

    /**
     * 保存
     *
     * @param tInfoGuideScheme
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveTInfoGuideScheme(TInfoGuideScheme tInfoGuideScheme) {
        return save(tInfoGuideScheme);
    }

    /**
     * 修改
     *
     * @param tInfoGuideScheme
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean modify(TInfoGuideScheme tInfoGuideScheme) {
        return updateById(tInfoGuideScheme);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteById(Integer id) {
        if (id == null){
            return false;
        }
        LambdaUpdateWrapper<TInfoGuideScheme> lambdaUpdateWrapper = new UpdateWrapper<TInfoGuideScheme>().lambda()
            .eq(TInfoGuideScheme::getId, id)
            .set(TInfoGuideScheme::getDelFlg, 1);
        return update(lambdaUpdateWrapper);
    }
}
